package com.admin.service;

import com.data.entity.User;
import com.data.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {
    @Resource
    private UserMapper userMapper;

    public List<User> listPage(Integer page, Integer limit) {
        if(page>0){
            page=(page-1)*limit;
        }
        return userMapper.listPage(page,limit);
    }

    public int count() {
        return userMapper.count();
    }

    public User getInfo(Long id) {
        return userMapper.selectById(id);
    }

    public int add(User user) {
        return userMapper.insert(user);
    }

    public int delete(Long id) {
        return userMapper.deleteById(id);
    }

    public int edit(User user) {
        return userMapper.updateById(user);
    }
}
